package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("setting/headline")
public @caption("品牌头条") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("headline") class Headline implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("所属品牌") @column("merchant")      @relate("$merchant") @RelateClass(Merchant.class)  @note("  ") Long merchant;//     
			
 	private transient Merchant $merchant;//关联对象[品牌信息]
 			
 			
 			
 		
	
		
	private @caption("文章标题") @column("title")     @notnull  @note("  ") String title;// 非空     
			
 			
 			
 		
	
		
	private @caption("列表图") @column("images")   @hidden   @notnull  @note("  ") String images;// 非空     
			
 			
 			
 		
	
		
	private @caption("正文") @column("content") @like  @hidden   @notnull  @note("  ") String content;// 非空     
			
 			
 			
 		
	
		
	private @caption("排序") @column("h_sort")      @note("  ") Integer hSort;//     
			
 			
 			
 		
	
		
	private @caption("来源媒体") @column("source")     @notnull  @note("  ") String source;// 非空     
			
 			
 			
 		
	
		
	private @caption("是否滚动") @column("scroll")      @note(" 0:否 1:是  ") Short scroll;// 0:否 1:是     
			
 			
 			
 		
	
		
	private @caption("关联商品") @column("commod")      @relate("$commod") @RelateClass(Commodity.class)  @note("  ") Long commod;//     
			
 	private transient Commodity $commod;//关联对象[商品信息]
 			
 			
 			
 		
	
		
	private @caption("相关文章") @column("related_articles")   @hidden    @relate("$relatedArticles") @RelateClass(Headline.class)  @note("  ") String relatedArticles;//     
			
 	private transient Headline $relatedArticles;//关联对象[品牌头条]
 			
 			
 			
 		
	
		
	private @caption("修改时间") @column("update_time")     @notnull  @note("  ") Date updateTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("添加时间") @column("add_time")     @notnull  @note("  ") Date addTime;// 非空     
			
 			
 			
 		
	
	 
	//默认构造函数
	public Headline(){ 
	
	}
	
	//主键构造函数
	public Headline(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 Headline(
	 	Utils.getLong("")//所属品牌
	 	,Utils.getString("")//文章标题 [非空]
	 	,Utils.getString("")//列表图 [非空]
	 	,Utils.getString("")//正文 [非空]
	 	,Utils.getInteger("sort")//排序
	 	,Utils.getString("")//来源媒体 [非空]
	 	,Utils.getShort("")//是否滚动
	 	,Utils.getLong("")//关联商品
	 	,Utils.getString("articles")//相关文章
	 	,Utils.getDate("time")//修改时间 [非空]
	 	,Utils.getDate("time")//添加时间 [非空]
	 )
	**/
	public Headline(Long merchant,String title,String images,String content,Integer hSort,String source,Short scroll,Long commod,String relatedArticles,Date updateTime,Date addTime){
		
			
			
		this.merchant=merchant;
		
			
		this.title=title;
		
			
		this.images=images;
		
			
		this.content=content;
		
			
		this.hSort=hSort;
		
			
		this.source=source;
		
			
		this.scroll=scroll;
		
			
		this.commod=commod;
		
			
		this.relatedArticles=relatedArticles;
		
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
	}
	
	//设置非空字段
	public Headline setNotNull(String title,String images,String content,String source,Date updateTime,Date addTime){
		
			
			
			
		this.title=title;
		
			
		this.images=images;
		
			
		this.content=content;
		
			
			
		this.source=source;
		
			
			
			
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public Headline id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	
		
	/** 所属品牌  [Merchant]      **/
	public Headline merchant(Long merchant){
		this.merchant = merchant;
		this.setSeted(F.merchant);
		return this;
	}
	
		
	/** 文章标题 [非空]       **/
	public Headline title(String title){
		this.title = title;
		this.setSeted(F.title);
		return this;
	}
	
		
	/** 列表图 [非空]       **/
	public Headline images(String images){
		this.images = images;
		this.setSeted(F.images);
		return this;
	}
	
		
	/** 正文 [非空]       **/
	public Headline content(String content){
		this.content = content;
		this.setSeted(F.content);
		return this;
	}
	
		
	/** 排序        **/
	public Headline hSort(Integer hSort){
		this.hSort = hSort;
		this.setSeted(F.hSort);
		return this;
	}
	
		
	/** 来源媒体 [非空]       **/
	public Headline source(String source){
		this.source = source;
		this.setSeted(F.source);
		return this;
	}
	
		
	/** 是否滚动    0:否 1:是     **/
	public Headline scroll(Short scroll){
		this.scroll = scroll;
		this.setSeted(F.scroll);
		return this;
	}
	
		
	/** 关联商品  [Commodity]      **/
	public Headline commod(Long commod){
		this.commod = commod;
		this.setSeted(F.commod);
		return this;
	}
	
		
	/** 相关文章  [Headline]      **/
	public Headline relatedArticles(String relatedArticles){
		this.relatedArticles = relatedArticles;
		this.setSeted(F.relatedArticles);
		return this;
	}
	
		
	/** 修改时间 [非空]       **/
	public Headline updateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
		return this;
	}
	
		
	/** 添加时间 [非空]       **/
	public Headline addTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public Headline clone(){
		Headline clone = new Headline();
		
			
			
		clone.merchant=this.merchant;
		
			
		clone.title=this.title;
		
			
		clone.images=this.images;
		
			
		clone.content=this.content;
		
			
		clone.hSort=this.hSort;
		
			
		clone.source=this.source;
		
			
		clone.scroll=this.scroll;
		
			
		clone.commod=this.commod;
		
			
		clone.relatedArticles=this.relatedArticles;
		
			
		clone.updateTime=this.updateTime;
		
			
		clone.addTime=this.addTime;
		
		return clone;
	}
	
	
	
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(Headline.M.class);
		Cache.clearValue(Headline.M.class);
		Cache.deleteObject(Headline.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(Headline.M.class);
		Cache.clearValue(Headline.M.class);
		Cache.deleteObject(Headline.class, id);
	}
	
	
	
	/**
	 * 根据ID取品牌头条
	 * @param id
	 * @return
	 */
	public static @api Headline get(Long id){		
		return getHeadlineById(id);
	}
	
	
	
	/**
	 * 获取所有品牌头条
	 * @return
	 */
	public static @api List<Headline> list(Map params,Integer size){
		return getHeadlineList(params,size);
	}
	/**
	 * 获取品牌头条分页
	 * @return
	 */
	public static @api Page<Headline> page(Integer page,Integer size,Map params){
		return getHeadlinePage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取品牌头条
	 * @param params
	 * @return
	 */
	public static @api Headline Get(Map params){
		return getHeadline(params);
	}
	/**
	 * 获取品牌头条数
	 * @return
	 */
	public static @api Long count(Map params){
		return getHeadlineCount(params);
	}
	/**
	 * 获取品牌头条数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getHeadlineEval(eval,params);
	}
	
	
	/**
	 * 获取品牌头条图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getHeadlineStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取品牌头条图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getHeadlineStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取品牌头条
	 * @param id
	 * @return
	 */
	public static @api Headline getHeadlineById(Long id){		
		return getHeadlineDao().getHeadlineById(id);
	}
	
	
	
	
	/**
	 * 根据ID取品牌头条的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
		
		value = Cache.getValue(Headline.class, id);
				
		if(value==null){
			Headline headline = get(id);
			if(headline!=null){
				String strValue = headline.getTitle$();
				
				if(!"Title".equals("Title"))
					strValue+="("+headline.getTitle$()+")";
				
				
				Cache.setValue(Headline.class, id ,strValue);
				
				value = strValue;
			}else{
				
				Cache.setValue(Headline.class, id ,"{"+id+"}",30);
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getTitle$();
		
		if(!"Title".equals("Title"))
			keyValue+="("+this.getTitle$()+")";
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询品牌头条对象
	 * @return
	 */
	public static @api Headline find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex+=" or title = '"+key.replaceAll("'", "''")+"'";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return Headline.getHeadline(params);
	}
	
	
	/**
	 * 根据关键字查询品牌头条
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex+=" or title like '%"+strTerm.replaceAll("'", "''")+"%'";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<Headline> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(Headline headline:list){
			Map map = new HashMap();
			map.put("key",headline.getId().toString());
			map.put("value", Utils.js(headline.getKeyValue()));
			if(bObject==true)
				map.put("object",headline);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有品牌头条
	 * @return
	 */
	public static @api List<Headline> getHeadlineList(Map params,Integer size){
		return getHeadlineDao().getHeadlineList(params,0,size);
	}
	
	/**
	 * 获取品牌头条分页
	 * @return
	 */
	public static @api Page<Headline> getHeadlinePage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getHeadlineDao().getHeadlinePage(page, size , params);
	}
	
	/**
	 * 根据查询条件取品牌头条
	 * @param params
	 * @return
	 */
	public static @api Headline getHeadline(Map params){
		return getHeadlineDao().getHeadline(params);
	}
	
	/**
	 * 保存一个品牌头条
	 * @param headline
	 * @return
	 */
	public static @api Headline saveHeadline(Headline headline){
		return getHeadlineDao().saveHeadline(headline);
	}
	
	/**
	 * 根据条件更新品牌头条
	 * @param values
	 * @param params
	 */
	public static @api int updateHeadlineByConfirm(Map values, Map params){
		return getHeadlineDao().updateHeadlineByConfirm(values,params);
	}
	
	/**
	 * 修改一个品牌头条
	 * @param headline
	 * @return
	 */
	public static @api int updateHeadline(Headline headline){
		return getHeadlineDao().updateHeadline(headline);
	}
	
	/**
	 * 更新品牌头条非空字段
	 * @param headline
	 */
	public static @api int updateHeadline$NotNull(Headline headline){
		return getHeadlineDao().updateHeadline$NotNull(headline);
	}
	
	/**
	 * 获取品牌头条数
	 * @return
	 */
	public static @api Long getHeadlineCount(Map params){
		return getHeadlineDao().getHeadlineCount(params);
	}
		
		
	/**
	 * 获取品牌头条自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getHeadlineEval(String eval,Map params){
		return getHeadlineDao().getHeadlineEval(eval,params);
	}
	
	
	/**
	 * 获取品牌头条图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getHeadlineStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getHeadlineDao().getHeadlineStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = Headline.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(Headline.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateHeadline(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getHeadlineDao().updateHeadlineByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteHeadline(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getHeadlineDao().deleteHeadlineByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getHeadlineDao().deleteHeadlineById(id);
		
	}
	
	
	/**
	 * 保存品牌头条对象
	 * @param params
	 * @return
	 */
	public Headline save(){
		if(this.getId()!=null)
			getHeadlineDao().updateHeadline(this);
		else
			return getHeadlineDao().saveHeadline(this);
		return this;
	}
	
	
	/**
	 * 更新品牌头条对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getHeadlineDao().updateHeadline$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
			getHeadlineDao().deleteHeadlineById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getHeadlineDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		
		if(this.id!=null){
			return this.id;
		}
		
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	
	
	 	this.id=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		
		this.setSeted(F.id);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************所属品牌**********************************/	
	/**
	* 所属品牌  [Merchant]     
	**/
	public Long getMerchant(){
		
		if(this.merchant!=null){
			return this.merchant;
		}
		
		return this.merchant;
	}
	/**
	* 获取所属品牌格式化(toString)
	**/
	public String getMerchant$(){
		String strValue="";
	
	
		 
		if(this.getMerchant()!=null){
			
				strValue+=Utils.string(Merchant.getKeyValue(this.getMerchant()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据所属品牌反格式化
	**/
	public void setMerchant$(String strValue){
		if(Utils.empty(strValue)){
			this.merchant=null;
			return;
		}
	
	
		 
		Merchant item = Merchant.find(strValue);
		if(item!=null){
			
			this.merchant = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 所属品牌  [Merchant]     
	**/
	public void setMerchant(Long merchant){
		this.merchant = merchant;
		
		this.setSeted(F.merchant);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[品牌信息]
	**/	 			
 	public Merchant get$merchant(){
 		if(this.$merchant!=null)
 			return this.$merchant;
 		com.distribute.framework.model.Merchant merchant = null;
		if(this.getMerchant()!=null){
		
 			merchant = Merchant.get(this.getMerchant());
 		
 		}
 		return merchant;
	}
	
 	
	
	
	/*******************************文章标题**********************************/	
	/**
	* 文章标题 [非空]      
	**/
	public String getTitle(){
		
		if(this.title!=null){
			return this.title;
		}
		
		return this.title;
	}
	/**
	* 获取文章标题格式化(toString)
	**/
	public String getTitle$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTitle());
	 
	 	 return strValue;
	}
	/**
	* 根据文章标题反格式化
	**/
	public void setTitle$(String strValue){
		if(Utils.empty(strValue)){
			this.title=null;
			return;
		}
	
	
	 	this.title=strValue;
	 
	}
	
	/**
	* 文章标题 [非空]      
	**/
	public void setTitle(String title){
		this.title = title;
		
		this.setSeted(F.title);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************列表图**********************************/	
	/**
	* 列表图 [非空]      
	**/
	public String getImages(){
		
		if(this.images!=null){
			return this.images;
		}
		
		return this.images;
	}
	/**
	* 获取列表图格式化(toString)
	**/
	public String getImages$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getImages());
	 
	 	 return strValue;
	}
	/**
	* 根据列表图反格式化
	**/
	public void setImages$(String strValue){
		if(Utils.empty(strValue)){
			this.images=null;
			return;
		}
	
	
		this.images=Utils.parseString(strValue);
	 
	}
	
	/**
	* 列表图 [非空]      
	**/
	public void setImages(String images){
		this.images = images;
		
		this.setSeted(F.images);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************正文**********************************/	
	/**
	* 正文 [非空]      
	**/
	public String getContent(){
		
		if(this.content!=null){
			return this.content;
		}
		
		return this.content;
	}
	/**
	* 获取正文格式化(toString)
	**/
	public String getContent$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getContent());
	 
	 	 return strValue;
	}
	/**
	* 根据正文反格式化
	**/
	public void setContent$(String strValue){
		if(Utils.empty(strValue)){
			this.content=null;
			return;
		}
	
	
		this.content=strValue;
	 
	}
	
	/**
	* 正文 [非空]      
	**/
	public void setContent(String content){
		this.content = content;
		
		this.setSeted(F.content);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************排序**********************************/	
	/**
	* 排序       
	**/
	public Integer gethSort(){
		
		if(this.hSort!=null){
			return this.hSort;
		}
		
		return this.hSort;
	}
	/**
	* 获取排序格式化(toString)
	**/
	public String gethSort$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.gethSort());
	 
	 	 return strValue;
	}
	/**
	* 根据排序反格式化
	**/
	public void sethSort$(String strValue){
		if(Utils.empty(strValue)){
			this.hSort=null;
			return;
		}
	
	
	 	this.hSort=Utils.parseInteger(strValue);
	 
	}
	
	/**
	* 排序       
	**/
	public void sethSort(Integer hSort){
		this.hSort = hSort;
		
		this.setSeted(F.hSort);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************来源媒体**********************************/	
	/**
	* 来源媒体 [非空]      
	**/
	public String getSource(){
		
		if(this.source!=null){
			return this.source;
		}
		
		return this.source;
	}
	/**
	* 获取来源媒体格式化(toString)
	**/
	public String getSource$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getSource());
	 
	 	 return strValue;
	}
	/**
	* 根据来源媒体反格式化
	**/
	public void setSource$(String strValue){
		if(Utils.empty(strValue)){
			this.source=null;
			return;
		}
	
	
	 	this.source=strValue;
	 
	}
	
	/**
	* 来源媒体 [非空]      
	**/
	public void setSource(String source){
		this.source = source;
		
		this.setSeted(F.source);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************是否滚动**********************************/	
	/**
	* 是否滚动    0:否 1:是    
	**/
	public Short getScroll(){
		
		if(this.scroll!=null){
			return this.scroll;
		}
		
		return this.scroll;
	}
	/**
	* 获取是否滚动格式化(toString)
	**/
	public String getScroll$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getScroll()),"0"))
			strValue=Utils.string("否");		 
			
		 if(Utils.equals(Utils.string(this.getScroll()),"1"))
			strValue=Utils.string("是");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据是否滚动反格式化
	**/
	public void setScroll$(String strValue){
		if(Utils.empty(strValue)){
			this.scroll=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"否"))
		 	this.scroll=Utils.parseShort("0");
			
		 if(Utils.equals(strValue,"是"))
		 	this.scroll=Utils.parseShort("1");
			
		
	 
	}
	
	/**
	* 是否滚动    0:否 1:是    
	**/
	public void setScroll(Short scroll){
		this.scroll = scroll;
		
		this.setSeted(F.scroll);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************关联商品**********************************/	
	/**
	* 关联商品  [Commodity]     
	**/
	public Long getCommod(){
		
		if(this.commod!=null){
			return this.commod;
		}
		
		return this.commod;
	}
	/**
	* 获取关联商品格式化(toString)
	**/
	public String getCommod$(){
		String strValue="";
	
	
		 
		if(this.getCommod()!=null){
			
				strValue+=Utils.string(Commodity.getKeyValue(this.getCommod()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据关联商品反格式化
	**/
	public void setCommod$(String strValue){
		if(Utils.empty(strValue)){
			this.commod=null;
			return;
		}
	
	
		 
		Commodity item = Commodity.find(strValue);
		if(item!=null){
			
			this.commod = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 关联商品  [Commodity]     
	**/
	public void setCommod(Long commod){
		this.commod = commod;
		
		this.setSeted(F.commod);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[商品信息]
	**/	 			
 	public Commodity get$commod(){
 		if(this.$commod!=null)
 			return this.$commod;
 		com.distribute.framework.model.Commodity commodity = null;
		if(this.getCommod()!=null){
		
 			commodity = Commodity.get(this.getCommod());
 		
 		}
 		return commodity;
	}
	
 	
	
	
	/*******************************相关文章**********************************/	
	/**
	* 相关文章  [Headline]     
	**/
	public String getRelatedArticles(){
		
		if(this.relatedArticles!=null){
			return this.relatedArticles;
		}
		
		return this.relatedArticles;
	}
	/**
	* 获取相关文章格式化(toString)
	**/
	public String getRelatedArticles$(){
		String strValue="";
	
	
		 
			
		if(!Utils.empty(this.getRelatedArticles())){
			List<com.distribute.framework.model.Headline> items = com.distribute.framework.model.Headline.getHeadlineList(Utils.add("definex","id in ("+Utils.string(this.getRelatedArticles()).replace("#","")+")"),-1);
			for(com.distribute.framework.model.Headline item1:items)
				strValue+="["+Utils.string(item1.getTitle$())+"]";
		}
				
		
	 
	 	 return strValue;
	}
	/**
	* 根据相关文章反格式化
	**/
	public void setRelatedArticles$(String strValue){
		if(Utils.empty(strValue)){
			this.relatedArticles=null;
			return;
		}
	
	
		 
			
		String strIds = "";
		for(String strItem:strValue.split(",")){
			Headline item = Headline.find(strItem);
			if(item!=null){
				strIds+=(strIds.equals("")?"":",")+"#"+item.getId()+"#";
			}
		}
		this.relatedArticles = strIds;
				
		
	 
	}
	
	/**
	* 相关文章  [Headline]     
	**/
	public void setRelatedArticles(String relatedArticles){
		this.relatedArticles = relatedArticles;
		
		this.setSeted(F.relatedArticles);
		
	}
	
	
		 
			
	/**
	* 获取相关文章列表
	**/ 			
 	public List<com.distribute.framework.model.Headline> get$relatedArticles(){
		if(!Utils.empty(this.getRelatedArticles())){
			return com.distribute.framework.model.Headline.getHeadlineList(Utils.add("definex","id in ("+Utils.string(this.getRelatedArticles()).replace("#","")+")"),-1);
		}else
			return new ArrayList();
	}
								 	 
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getUpdateTime(){
		
		if(this.updateTime!=null){
			return this.updateTime;
		}
		
		return this.updateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getUpdateTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.updateTime=null;
			return;
		}
	
	
	 	this.updateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setUpdateTime(Date updateTime){
		this.updateTime = updateTime;
		
		this.setSeted(F.updateTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getAddTime(){
		
		if(this.addTime!=null){
			return this.addTime;
		}
		
		return this.addTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getAddTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getAddTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.addTime=null;
			return;
		}
	
	
	 	this.addTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setAddTime(Date addTime){
		this.addTime = addTime;
		
		this.setSeted(F.addTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(Headline.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(Headline.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(Headline.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(Headline.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(Headline.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${Headline.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Headline.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Headline.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(Headline.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${Headline.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Headline.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Headline.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(Headline.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	 		
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
			
			
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M merchant$on(Merchant.M value){if(proxy)return proxy().merchant$on(value);this.put("Merchant", value);value.put("on", "merchant");return this;};
 				
 			
		
		/** 所属品牌  [Merchant]      **/
		public M merchant(Object merchant){if(proxy)return proxy().merchant(merchant);  this.put("merchant", merchant);return this;};
	 	/** and merchant is null */
 		public M merchantNull(){if(proxy)return proxy().merchantNull();if(this.get("merchantNot")==null)this.put("merchantNot", "");this.put("merchant", null);return this;};
 		/** not .... */
 		public M merchantNot(){if(proxy)return proxy().merchantNot();this.put("merchantNot", "not");return this;};
 		public M merchantNotNull(){if(proxy)return proxy().merchantNotNull();this.put("merchantNot", "not");this.put("merchant", null);return this;};
 		public M merchantNot(Object merchant){if(proxy)return proxy().merchantNot(merchant);this.put("merchantNot", "not");this.put("merchant", merchant);return this;};
	 		
			
		public M merchantIn(String ids){
			if(proxy)return proxy().merchantIn(ids);  this.put("merchantIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 文章标题 [非空]       **/
		public M title(Object title){if(proxy)return proxy().title(title);  this.put("title", title);return this;};
	 	/** and title is null */
 		public M titleNull(){if(proxy)return proxy().titleNull();if(this.get("titleNot")==null)this.put("titleNot", "");this.put("title", null);return this;};
 		/** not .... */
 		public M titleNot(){if(proxy)return proxy().titleNot();this.put("titleNot", "not");return this;};
 		public M titleNotNull(){if(proxy)return proxy().titleNotNull();this.put("titleNot", "not");this.put("title", null);return this;};
 		public M titleNot(Object title){if(proxy)return proxy().titleNot(title);this.put("titleNot", "not");this.put("title", title);return this;};
	 		
			
		
			
	 	
			
		
		/** 列表图 [非空]       **/
		public M images(Object images){if(proxy)return proxy().images(images);  this.put("images", images);return this;};
	 	/** and images is null */
 		public M imagesNull(){if(proxy)return proxy().imagesNull();if(this.get("imagesNot")==null)this.put("imagesNot", "");this.put("images", null);return this;};
 		/** not .... */
 		public M imagesNot(){if(proxy)return proxy().imagesNot();this.put("imagesNot", "not");return this;};
 		public M imagesNotNull(){if(proxy)return proxy().imagesNotNull();this.put("imagesNot", "not");this.put("images", null);return this;};
 		public M imagesNot(Object images){if(proxy)return proxy().imagesNot(images);this.put("imagesNot", "not");this.put("images", images);return this;};
	 		
			
		
			
	 	
			
		
		/** 正文 [非空]       **/
		public M content(Object content){if(proxy)return proxy().content(content);  this.put("content", content);return this;};
	 	/** and content is null */
 		public M contentNull(){if(proxy)return proxy().contentNull();if(this.get("contentNot")==null)this.put("contentNot", "");this.put("content", null);return this;};
 		/** not .... */
 		public M contentNot(){if(proxy)return proxy().contentNot();this.put("contentNot", "not");return this;};
 		public M contentNotNull(){if(proxy)return proxy().contentNotNull();this.put("contentNot", "not");this.put("content", null);return this;};
 		public M contentNot(Object content){if(proxy)return proxy().contentNot(content);this.put("contentNot", "not");this.put("content", content);return this;};
	 		
			
		
			
	 	
			
		
		/** 排序        **/
		public M hSort(Object hSort){if(proxy)return proxy().hSort(hSort);  this.put("hSort", hSort);return this;};
	 	/** and h_sort is null */
 		public M hSortNull(){if(proxy)return proxy().hSortNull();if(this.get("hSortNot")==null)this.put("hSortNot", "");this.put("hSort", null);return this;};
 		/** not .... */
 		public M hSortNot(){if(proxy)return proxy().hSortNot();this.put("hSortNot", "not");return this;};
 		public M hSortNotNull(){if(proxy)return proxy().hSortNotNull();this.put("hSortNot", "not");this.put("hSort", null);return this;};
 		public M hSortNot(Object hSort){if(proxy)return proxy().hSortNot(hSort);this.put("hSortNot", "not");this.put("hSort", hSort);return this;};
	 		
		/** and h_sort <= ? */
		public M hSortMin(Object min){if(proxy)return proxy().hSortMin(min);this.put("hSortMin", min);return this;};
		/** and h_sort >= ? */
		public M hSortMax(Object max){if(proxy)return proxy().hSortMax(max);this.put("hSortMax", max);return this;};
			
			
		public M hSortIn(String ids){
			if(proxy)return proxy().hSortIn(ids);  this.put("hSortIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 来源媒体 [非空]       **/
		public M source(Object source){if(proxy)return proxy().source(source);  this.put("source", source);return this;};
	 	/** and source is null */
 		public M sourceNull(){if(proxy)return proxy().sourceNull();if(this.get("sourceNot")==null)this.put("sourceNot", "");this.put("source", null);return this;};
 		/** not .... */
 		public M sourceNot(){if(proxy)return proxy().sourceNot();this.put("sourceNot", "not");return this;};
 		public M sourceNotNull(){if(proxy)return proxy().sourceNotNull();this.put("sourceNot", "not");this.put("source", null);return this;};
 		public M sourceNot(Object source){if(proxy)return proxy().sourceNot(source);this.put("sourceNot", "not");this.put("source", source);return this;};
	 		
			
		
			
	 	
			
		
		/** 是否滚动    0:否 1:是     **/
		public M scroll(Object scroll){if(proxy)return proxy().scroll(scroll);  this.put("scroll", scroll);return this;};
	 	/** and scroll is null */
 		public M scrollNull(){if(proxy)return proxy().scrollNull();if(this.get("scrollNot")==null)this.put("scrollNot", "");this.put("scroll", null);return this;};
 		/** not .... */
 		public M scrollNot(){if(proxy)return proxy().scrollNot();this.put("scrollNot", "not");return this;};
 		public M scrollNotNull(){if(proxy)return proxy().scrollNotNull();this.put("scrollNot", "not");this.put("scroll", null);return this;};
 		public M scrollNot(Object scroll){if(proxy)return proxy().scrollNot(scroll);this.put("scrollNot", "not");this.put("scroll", scroll);return this;};
	 		
			
		public M scrollIn(String ids){
			if(proxy)return proxy().scrollIn(ids);  this.put("scrollIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M commod$on(Commodity.M value){if(proxy)return proxy().commod$on(value);this.put("Commod", value);value.put("on", "commod");return this;};
 				
 			
		
		/** 关联商品  [Commodity]      **/
		public M commod(Object commod){if(proxy)return proxy().commod(commod);  this.put("commod", commod);return this;};
	 	/** and commod is null */
 		public M commodNull(){if(proxy)return proxy().commodNull();if(this.get("commodNot")==null)this.put("commodNot", "");this.put("commod", null);return this;};
 		/** not .... */
 		public M commodNot(){if(proxy)return proxy().commodNot();this.put("commodNot", "not");return this;};
 		public M commodNotNull(){if(proxy)return proxy().commodNotNull();this.put("commodNot", "not");this.put("commod", null);return this;};
 		public M commodNot(Object commod){if(proxy)return proxy().commodNot(commod);this.put("commodNot", "not");this.put("commod", commod);return this;};
	 		
			
		public M commodIn(String ids){
			if(proxy)return proxy().commodIn(ids);  this.put("commodIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M relatedArticles$on(Headline.M value){if(proxy)return proxy().relatedArticles$on(value);this.put("RelatedArticles", value);value.put("on", "related_articles");return this;};
 				
 			
		
		/** 相关文章  [Headline]      **/
		public M relatedArticles(Object relatedArticles){if(proxy)return proxy().relatedArticles(relatedArticles);  this.put("relatedArticles", relatedArticles);return this;};
	 	/** and related_articles is null */
 		public M relatedArticlesNull(){if(proxy)return proxy().relatedArticlesNull();if(this.get("relatedArticlesNot")==null)this.put("relatedArticlesNot", "");this.put("relatedArticles", null);return this;};
 		/** not .... */
 		public M relatedArticlesNot(){if(proxy)return proxy().relatedArticlesNot();this.put("relatedArticlesNot", "not");return this;};
 		public M relatedArticlesNotNull(){if(proxy)return proxy().relatedArticlesNotNull();this.put("relatedArticlesNot", "not");this.put("relatedArticles", null);return this;};
 		public M relatedArticlesNot(Object relatedArticles){if(proxy)return proxy().relatedArticlesNot(relatedArticles);this.put("relatedArticlesNot", "not");this.put("relatedArticles", relatedArticles);return this;};
	 		
			
		
			
	 	
			
		
		/** 修改时间 [非空]       **/
		public M updateTime(Object updateTime){if(proxy)return proxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	 	/** and update_time is null */
 		public M updateTimeNull(){if(proxy)return proxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
 		/** not .... */
 		public M updateTimeNot(){if(proxy)return proxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
 		public M updateTimeNotNull(){if(proxy)return proxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
 		public M updateTimeNot(Object updateTime){if(proxy)return proxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	 		
 		/** and update_time >= ? */
 		public M updateTimeStart(Object start){if(proxy)return proxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
 		/** and update_time <= ? */
 		public M updateTimeEnd(Object end){if(proxy)return proxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 添加时间 [非空]       **/
		public M addTime(Object addTime){if(proxy)return proxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	 	/** and add_time is null */
 		public M addTimeNull(){if(proxy)return proxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
 		/** not .... */
 		public M addTimeNot(){if(proxy)return proxy().addTimeNot();this.put("addTimeNot", "not");return this;};
 		public M addTimeNotNull(){if(proxy)return proxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
 		public M addTimeNot(Object addTime){if(proxy)return proxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	 		
 		/** and add_time >= ? */
 		public M addTimeStart(Object start){if(proxy)return proxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
 		/** and add_time <= ? */
 		public M addTimeEnd(Object end){if(proxy)return proxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
			
			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有品牌头条 **/
		public @api List<Headline> list(Integer size){			
			return getHeadlineList(this,size);
		}
		/** 获取品牌头条分页 **/
		public @api Page<Headline> page(Integer page,Integer size){			
			return getHeadlinePage(page, size , this);
		}
		/** 根据查询条件取品牌头条 **/
		public @api Headline get(){			
			return getHeadline(this);
		}
		/** 获取品牌头条数 **/
		public @api Long count(){			
			return getHeadlineCount(this);
		}
		/** 获取品牌头条表达式 **/
		public @api <T> T eval(String strEval){			
			return getHeadlineEval(strEval,this);
		}
		
		/** 获取品牌头条统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getHeadlineStats(this,sumKey,groupKey,dateType);
		}
		/** 获取品牌头条统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getHeadlineStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateHeadline(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteHeadline(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
	 			
			
	 	
			
		/** 所属品牌  [Merchant]      **/
		public final static @type(Long.class)  String merchant="merchant";
	 			
			
	 	
			
		/** 文章标题 [非空]       **/
		public final static @type(String.class)  String title="title";
	 			
			
	 	
			
		/** 列表图 [非空]       **/
		public final static @type(String.class)  String images="images";
	 			
			
	 	
			
		/** 正文 [非空]       **/
		public final static @type(String.class) @like String content="content";
	 			
			
	 	
			
		/** 排序        **/
		public final static @type(Integer.class)  String hSort="hSort";
	 			
		/** and h_sort >= ? */
		public final static @type(Integer.class) String hSortMin="hSortMin";
		/** and h_sort <= ? */
		public final static @type(Integer.class) String hSortMax="hSortMax";
				
			
	 	
			
		/** 来源媒体 [非空]       **/
		public final static @type(String.class)  String source="source";
	 			
			
	 	
			
		/** 是否滚动    0:否 1:是     **/
		public final static @type(Short.class)  String scroll="scroll";
	 			
			
	 	
			
		/** 关联商品  [Commodity]      **/
		public final static @type(Long.class)  String commod="commod";
	 			
			
	 	
			
		/** 相关文章  [Headline]      **/
		public final static @type(String.class)  String relatedArticles="relatedArticles";
	 			
			
	 	
			
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String updateTime="updateTime";
	 			
	 	/** and update_time >= ? */
 		public final static @type(Date.class) String updateTimeStart="updateTimeStart";
 		/** and update_time <= ? */
 		public final static @type(Date.class) String updateTimeEnd="updateTimeEnd";
				
			
	 	
			
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String addTime="addTime";
	 			
	 	/** and add_time >= ? */
 		public final static @type(Date.class) String addTimeStart="addTimeStart";
 		/** and add_time <= ? */
 		public final static @type(Date.class) String addTimeEnd="addTimeEnd";
				
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		id("id"),
		merchant("merchant"),
		title("title"),
		images("images"),
		content("content"),
		hSort("h_sort"),
		source("source"),
		scroll("scroll"),
		commod("commod"),
		relatedArticles("related_articles"),
		updateTime("update_time"),
		addTime("add_time"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取品牌头条数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = Headline.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = Headline.getHeadline(params);
			else
				value = Headline.getHeadlineList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  Headline.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = Headline.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getId());
	
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		
			
 		
	
		Utils.fms(map,simple?"":"merchant",this.getMerchant(),this.getMerchant$());
		
			
 		
	
		Utils.fms(map,simple?"":"title",this.getTitle(),this.getTitle$());
		
			
 		
	
		Utils.fms(map,simple?"":"images",this.getImages(),this.getImages$());
		
			
 		
	
		Utils.fms(map,simple?"":"content",this.getContent(),this.getContent$());
		
			
 		
	
		Utils.fms(map,simple?"sort":"hSort",this.gethSort(),this.gethSort$());
		
			
 		
	
		Utils.fms(map,simple?"":"source",this.getSource(),this.getSource$());
		
			
 		
	
		Utils.fms(map,simple?"":"scroll",this.getScroll(),this.getScroll$());
		
			
 		
	
		Utils.fms(map,simple?"":"commod",this.getCommod(),this.getCommod$());
		
			
 		
	
 		if(!Utils.empty(this.getRelatedArticles())){
 			Utils.fms(map,simple?"articles":"relatedArticles",this.getRelatedArticles().replace("#",""),this.getRelatedArticles$());
	 		List<Map> list = Headline.query(null,256,Utils.add("idIn",this.getRelatedArticles().replace("#","")),false);
	 		Map<String,Map> mapping = new HashMap();
	 		for(Map m:list)mapping.put(""+m.get("key"), m);
	 		List<Map> newList = new ArrayList();
	 		for(String itm:this.getRelatedArticles().replace("#","").split(",")){
	 			if(itm.equals("0"))continue;
	 			newList.add(mapping.get(itm));
	 		}
	 		map.put((simple?"articles":"relatedArticles")+"$list",newList);
 		}
 		
	
		Utils.fms(map,simple?"time":"updateTime",this.getUpdateTime(),this.getUpdateTime$());
		
			
 		
	
		Utils.fms(map,simple?"time":"addTime",this.getAddTime(),this.getAddTime$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("id",this.getId());
 		
	
		map.put("merchant",this.getMerchant());
 		
	
		map.put("title",this.getTitle());
 		
	
		map.put("images",this.getImages());
 		
	
		map.put("content",this.getContent());
 		
	
		map.put("hSort",this.gethSort());
 		
	
		map.put("source",this.getSource());
 		
	
		map.put("scroll",this.getScroll());
 		
	
		map.put("commod",this.getCommod());
 		
	
		map.put("relatedArticles",this.getRelatedArticles());
 		
	
		map.put("updateTime",this.getUpdateTime());
 		
	
		map.put("addTime",this.getAddTime());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static Headline fromMap(Map map){
		Headline headline = new Headline();
	
		headline.id = Utils.parseLong(map.get("id"));
 		
	
		headline.merchant = Utils.parseLong(map.get("merchant"));
 		
	
		headline.title = Utils.parseString(map.get("title"));
 		
	
		headline.images = Utils.parseString(map.get("images"));
 		
	
		headline.content = Utils.parseString(map.get("content"));
 		
	
		headline.hSort = Utils.parseInteger(map.get("hSort"));
 		
	
		headline.source = Utils.parseString(map.get("source"));
 		
	
		headline.scroll = Utils.parseShort(map.get("scroll"));
 		
	
		headline.commod = Utils.parseLong(map.get("commod"));
 		
	
		headline.relatedArticles = Utils.parseString(map.get("relatedArticles"));
 		
	
		headline.updateTime = Utils.parseDate(map.get("updateTime"));
 		
	
		headline.addTime = Utils.parseDate(map.get("addTime"));
 		
	
		return headline;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(Headline old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "/images/icons/20088256423873477801.png";
	}
	public static String getIconfont(){
		return "icon-tupian2";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,Headline.M params){
		if(params==null)params=new Headline.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/setting/headline.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/setting/headline.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(Headline.ACT act,Headline.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",Headline.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(Headline.ACT act,Headline.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",Headline.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IHeadlineDao getHeadlineDao(){
		return Utils.getBean("headlineDao");
	};
	
}